<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            display: flex;
        }

        .box {
            width: 40px;
            height: 35px;
            margin-left: 20px;
            margin-top: 20px;
            background-image: url(./下载.jpg);
            background-position: -40px 0;
        }
        .box2{
            width: 40px;
            height: 35px;
            margin-left: 20px;
            margin-top: 20px;
            background-image: url(./下载.jpg);
            background-position: 0 0;
          
        }
    </style>
</head>




<body>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box2"></div>
    <div class="box"></div>
    <div class="box"></div>

    <script>
        let box = document.querySelectorAll('.box');
        console.log(box);
        for (let item of box) {
            item.onclick = function () {
                item.classList.toggle('box2')
            }
        }
    </script>
</body>

</html>